import Configurable
import Util

class Item(Configurable.Configurable):
   runtime_vars = ('holder',
                   'icon')
   
   __slots__ = ('value',
                'iconpath') + runtime_vars
   
   def __init__(self, name, iconpath=None, value=0, description=""):
      Configurable.Configurable.__init__(self, locals())
      self.holder = None
      if iconpath is not None:
         if isinstance(iconpath, str):
            self.icon = Util.load_image(iconpath)[0]
         else:
            self.icon = Util.load_image(iconpath[0])[0]
      else:
         self.icon = None
   
   def add_item(self, target):
      target.items.append(self)
      self.holder = target
   
   def augmented_descriptio(self):
      return ""
   
   def get_value(self):
      return self.value
   
   def get_icon(self):
      return self.icon
      
   def remove_item(self):
      self.holder.items.remove(self)
      self.holder = None
